package com.donovosoft.api.common;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

import com.donovosoft.api.NetSender;
import com.donovosoft.api.Utils;
import com.donovosoft.api.exceptions.AuthenticationException;
import com.donovosoft.api.exceptions.PathNotFound;

public class SocketClient extends NetSender {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6321891450238482597L;
	private int type;

	public String send(String data) {
		String back = null;
		try {
			DatagramSocket socket = new DatagramSocket();
			byte[] data1 = Utils.nmaCommand(data);
			DatagramPacket datagram = new DatagramPacket(data1, data1.length,
					InetAddress.getByName(this.getHost()), this.getPort());
			socket.send(datagram);
			back = new String(datagram.getData());
			socket.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return back;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	@Override
	public boolean login() throws AuthenticationException {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void changeDir(String path) throws PathNotFound {
		// TODO Auto-generated method stub

	}

	@Override
	public String[] listFiles() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean deleteFile(String name) throws IOException {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean makeDir(String path) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean deleteDir(String path) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public long getModificationTime(String path) throws PathNotFound {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String currentDir() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean putFile(File stream) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public OutputStream getFile(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean logout() {
		// TODO Auto-generated method stub
		return false;
	}

}
